<%--
  Created by IntelliJ IDEA.
  User: DELL
  Date: 2020/11/13
  Time: 19:34
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>发布新公告</title>
    <style type="text/css" rel="stylesheet">
        body{
            font-family: "楷体";
            font-size: 16px;
        }
        .all{
            width: 850px;
            max-height: 450px;
            overflow: auto;
            border: 2px solid red;
            margin: 0 auto;
            padding: 50px 30px;
            box-sizing: border-box;
        }
        .yheader{
            font-size: 18px;
            font-weight: 600;
            color: red;
            margin-bottom: 10px;
        }
        .content{
            height: 280px;
            border:2px solid red;
            box-sizing: border-box;
            padding: 20px;
            overflow: auto;
        }
        .end{
            width: 700px;
            margin: 0 auto;
        }
        .end1{
            border: 2px solid red;
            border-top: none;
            box-sizing: border-box;
        }
        button{
            width: 100%;
            height: 30px;
            border: none;
            background: #a39933;
            line-height: 30px;
            display: block;
            margin: 0 auto;
            color: #fff;
            font-weight: 600;
            cursor: pointer;
        }
        button:hover{
            background: red;
        }
    </style>
    <script src="/WebContent/JQuery/jquery-3.4.1.js" type="text/javascript"></script>
</head>
<body>
<article class="all">
    <div class="yheader">当前位置&nbsp;&gt;&gt;&nbsp;发布新公告</div>
    <div class="content end" tabindex="1" contenteditable="true">

    </div>
    <div class="end end1">
        <button type="button" id="btn">发布</button>
    </div>
</article>
<script>
    $(document).ready(function () {
        $("#btn").click(function () {
            var cont = $.trim($(".content").text());
            $.ajax({
                url:"/SuperAdminServlet?type=ggcx",
                dataType:"json",
                async:true,
                type:"get",
                success:function (data) {
                    if(data != null){
                        alert("已存在公告，请删除后在发布！");
                        window.location.href = "glgonggao.jsp";
                    }else{
                         $.ajax({
                             url:"/SuperAdminServlet?type=fbgg&",
                             data:"content="+cont,
                             type: "post",
                             async: true,
                             dataType: "text",
                             success:function (data) {
                                 if(data == "1"){
                                     alert("发布成功！");
                                     window.location.href = "glgonggao.jsp";
                                 }else{
                                     alert("发布失败！");
                                 }
                             },
                             error:function (error) {
                                 alert("请求失败！");
                             }
                         })
                    }
                },
                error:function (error) {
                    alert("请求失败！");

                }
            })
        })
    })
</script>
</body>
</html>

